package com.example.qqfake;

import java.io.IOException;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Client1 {
    //唯一id号：0，代表登录的socket
    //1 代表注册的socket
    private final String serverAddress = "192.168.104.215";
    private final int serverPort = 50000; // 服务器监听的端口
    private Content msg;
    public Socket socket;
    public Client1() throws IOException {
        socket= new Socket(serverAddress, serverPort);
    }
    //content的内容从edittext获取，点击发送按钮，调用此方法，goal是自己
    public void send(String type,String id,String content) throws IOException {
        Date now = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String formattedString = formatter.format(now);

        msg = new Content(type,id,formattedString,content,id);
        msg.sendMessage(socket);

    }
    public Content receiver() throws IOException {
        return msg.getMessage(socket);

    }
}
